<template>
    <van-nav-bar title="详情" left-text="返回" left-arrow @click-left="onClickLeft" />
    <div>
        <van-swipe :autoplay="3000" lazy-render>
            <van-swipe-item v-for="i in xqdata.pics">
                <img style="width: 100%;" :src="i.pics_big_url" />
            </van-swipe-item>
        </van-swipe>

        <div v-html="xqdata.goods_introduce"></div>
    </div>

    <van-action-bar>
        <van-action-bar-icon icon="chat-o" text="客服" color="#ee0a24" />
        <van-action-bar-icon icon="cart-o" text="购物车" />
        <van-action-bar-icon icon="star" text="已收藏" color="#ff5000" />
        <van-action-bar-button type="warning" text="加入购物车" @click="jiaru" />
        <van-action-bar-button type="danger" text="立即购买" />
    </van-action-bar>
</template>

<script setup>
import { useCounterStore } from '@/stores/counter'
// 可以在组件中的任意位置访问 `store` 变量 ✨
const store = useCounterStore()
import { ref } from 'vue';

import { xq } from '@/api/api';
import { useRoute, useRouter } from 'vue-router';
const router = useRouter()
const onClickLeft = () => router.go(-1);
const route = useRoute()
let xqdata = ref({})
xq(route.params.id).then(res => {
    console.log('详情', res)
    xqdata.value = res.data.message;

})

const jiaru=()=>{
    store.add(xqdata.value,route.params.id)
    router.push('/home/shop')
}

</script>

<style lang="scss" scoped></style>